<template>
  <div>
<!--    <div style="position: absolute;bottom: 50%;left: 0px;background: #fff;padding: 0.3rem;cursor: pointer;" @click="clearCache">清除缓存</div>-->
<!--      <div style="position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;z-index: 99;height:100%;" @click="$toast('更多精彩 敬请期待');"></div>-->
<!--    <div v-if="!!userData.userId" class="_wz_add_ljsc">-->
<!--      <div style="line-height: 0.8rem;font-size: 0.35rem;font-weight: 900;">{{userData.name}}</div>-->
<!--      <div style="font-size: 0.2rem;line-height: 0.4rem;">累计学习时长：<span style="color: #f00;font-size: 0.3rem;padding: 0 0.1rem;">{{userData.minute}}</span>分</div>-->
<!--    </div>-->
    <div class="_wz_AppHome">
      <img src="../assets1/er/h5/homeTop.png" style="width: 100%;"/>
      <div style="display: flex;align-items: center;justify-content: center;flex-wrap: wrap">

        <div>
          <!--            会议简介-->
          <img src="../assets1/er/h5/an1.png" @click="enter('day')" style="width: 30%;"/>
          <!--            会议须知-->
          <img src="../assets1/er/h5/an2.png" @click="enter('know')" style="width: 30%;"/>
        </div>
        <div>
          <!--            线上展厅-->
          <img src="../assets1/er/h5/an3.png" @click="enter('onlineExhibitionHall')" style="width: 30%;"/>
          <!--            会议直播-->
          <img src="../assets1/er/h5/an4.png" @click="enter('liveList')" style="width: 30%;"/>
        </div>

      </div>

    </div>
    <peoplePopup ref="peoplePopup" @checkUser="checkUser"></peoplePopup>
  </div>
</template>
<script>
import wxApi from "@/utils/wxapi.js";
import peoplePopup from "@/components/peoplePopup.vue";
export default {
  components: {
    peoplePopup,//登录使用
  },
  data() {
    return {
      userData:!!localStorage.getItem("userData") ? JSON.parse(localStorage.getItem("userData")) : {},
      loading: true,//加载

    };
  },
  computed: {//计算属性

  },
  beforeCreate() {//beforeCreate创建前状态

  },
  created() {//created创建完毕状态

  },
  beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

  },
  //activated和deactivated配合keep-alive标签使用!
  activated () {
    console.log('实例被激活时使用')
  },
  deactivated () {
    console.log('实例没有被激活时')
  },
  mounted() {//mounted 挂载结束状态
    let that = this;
    console.log('挂载结束状态')
    //调用微信方法
    wxApi("", "", "https://prod.sumaokeji.com/h5/meeting/#/");

    //TODO
    // localStorage.clear();
    //判断用户是否登录
    if (!localStorage.getItem("userId")) {
      console.log('每次都从新获取新的用户数据')
      that.$refs.peoplePopup.open(that.$store.state.isMobile);
    } else {
      that.checkUser();
    }
  },
  methods: {//执行的方法
    enter(flag, type) {//跳转地址
      let that = this;
      if (flag == "live") {
        that.pushPage(`${flag}`, { type: type });
      } else {
        that.pushPage(`${flag}`);
      }
    },
    //检验用户是否过期
    checkUser() {
      let that = this;
      that.$toast.loading({message: "加载中...", forbidClick: true});
      that.http.checkUserId({userId: localStorage.getItem("userId")}).then(res => {
        that.$toast.clear();
        if (res.status == 1103) {
          that.$refs.peoplePopup.open(that.$store.state.isMobile);
          // that.$that.$toast("登录已过期，请重新登录");
        }else{
          if (res.status == 1000) {
            if(!!res.data){
              localStorage.setItem("userId", res.data.userId);
              localStorage.setItem("userData", JSON.stringify(res.data));
              that.userData = res.data;
            }else{
              that.userData = {};
              that.$refs.peoplePopup.open(that.$store.state.isMobile);
              that.clearCache()
            }
          }
        }
      }).catch(err => {
        that.$toast.clear();
      });
    },
    clearCache(){
      localStorage.clear();
    },
  },
  watch: {//监听

  },
  props: {//接收来自父组件的数据

  },
  beforeUpdate() {//beforeUpdate 更新前状态

  },
  updated() {//updated 更新完成状态

  },
  beforeDestroy() {//beforeDestroy 销毁前状态

  },
  destroyed() {//destroyed 销毁完成状态

  }
}
</script>

<style scoped lang="scss">
._wz_AppHome {
  background-image: url(../assets1/er/h5/indexBack.png);
  background-size: 100% 100%;
  width: 100%;
  //height: 23.47rem;
  height: 100%;
  position: fixed;
  top: 0px;
  left: 0px;
  right: 0px;
  bottom: 0px;
}
._wz_add_ljsc{
  position: absolute;
  right: 0px;
  background: url("../assets1/sc.png") no-repeat;
  background-size: 100% 100%;
  padding:0 0.4rem 0.4rem;
  top: 0px;
}
._wz_12-1-app_-baca{
  background-image: url(../assets1/pc/12-1-bac.png);
  background-repeat: no-repeat;
  background-size: 96% 100%;
  background-position: center;
  padding: 10px;
}
</style>
/*
  2.PC  和 APP  的 会议议程图 16 * 2
  3.会议须知图标
*/
